<template>
  <div class="webcastsRisk"></div>
</template>

<script>
import {getDistributionOfSex} from "@/api/patient";

export default {
  name: 'part2',
  data() {
    return {
      myChart: null,
      chartData: []
    }
  },
  methods: {
    getData() {
      getDistributionOfSex().then(res=> {
        this.chartData = res.data
        this.setWebcasts()

      })
    },
    // 网播风险分析
    setWebcasts() {
      let option = {

        tooltip: {
        },
        legend: {
          data: [
            {name: '男', icon: 'circle'},
            {name: '女', icon: 'circle'},
          ],
          gridIndex: 3,
          right: "5%",
          top: "6%",
          itemWidth: 7,
          itemHeight: 7,
          textStyle: {
            color: '#00CCFF',
            fontSize: 10
          }
        },
        grid: {
          top: '15%',
          left: '3%',
          right: '50%',
          bottom: '5%',
          containLabel: true
        },

        series: [
          {
            type: 'pie',
            radius: ['40%', '65%'],
            roseType: 'area',
            avoidLabelOverlap: true,
            startAngle: 180,
            label: {
              show: true,
              padding: [0, -30],
              formatter: '{c} \n\n',
              position: 'outside',
              color: '#fff',
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '30',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: true,
              length2: 30,
              lineStyle: {
              },

            },
            itemStyle: {
              color: function (params) {
                let corList = ["#142AFE", '#3FA0FF', "#00CCFF", "#1456FE"];
                return corList[params.dataIndex]
              }
            },
            data: this.chartData
          }
        ]
      };
      if (!this.myChart) this.myChart = this.$echarts(this.$el);

      this.myChart.clear();
      this.myChart.resize();
      this.myChart.setOption(option);
    },
  },
  mounted() {
    this.getData()
  },
}
</script>

<style lang="less" scoped>
.webcastsRisk {
  height: 100%;
}
</style>
